#include <REGX52.H>

unsigned char Nixie_Buf[9] = {0};//扫描用

void Nixie(unsigned char loc, num)
{
	unsigned char dt[12] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40}; //0~9,void,-
	
	P0 =0x00;
	
	switch(loc)
	{
		case 1: P2_2 = 0, P2_3 = 0, P2_4 = 0;
		break;
		case 2: P2_2 = 1, P2_3 = 0, P2_4 = 0;
		break;
		case 3: P2_2 = 0, P2_3 = 1, P2_4 = 0;
		break;
		case 4: P2_2 = 1, P2_3 = 1, P2_4 = 0;
		break;
		case 5: P2_2 = 0, P2_3 = 0, P2_4 = 1;
		break;
		case 6: P2_2 = 1, P2_3 = 0, P2_4 = 1;
		break;
		case 7: P2_2 = 0, P2_3 = 1, P2_4 = 1;
		break;
		case 8: P2_2 = 1, P2_3 = 1, P2_4 = 1;
		break;
	}
	

	P0 = dt[num];
}


void Nixie_Loop(void)//用定时器扫描该函数，每执行一次显示一位
{
	static unsigned char i;
	
	Nixie(i,Nixie_Buf[i]);
	
	i++;
	
	i = i%9;
}

void Set_Num(unsigned char loc,num)//输入时间
{
	Nixie_Buf[loc] = num;
}